require 'zlib'

class BrightkiteCrawl < ActiveRecord::Base
  belongs_to :service    # foreign key - service_id
  has_one :brightkite_data, :foreign_key => :crawl_id
  
  def data
    self.brightkite_data
  end
  
  def data=(new_data)
    self.brightkite_data = new_data
  end
  
  def create_data(args = {})
    create_brightkite_data args
  end
  
  def body
    if super.nil? then
      return nil
    else     
      return Zlib::Inflate.inflate super
    end
  end
  
  def body=(new_body)
    super Zlib::Deflate.deflate new_body.to_s  
  end
end
